<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,initial-scale=1.0,width=device-width" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>雇主评价</title>
    <link rel="stylesheet" type="text/css" href="../../../css/aui/aui.css" />
    <link rel="stylesheet" type="text/css" href="../../../css/swiper.min.css" />
    <style>
        body {
            background: #fff;
        }

        .user_head_info {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin: 0.6rem 0;
        }

        .list-item-inner {
            display: flex;
            justify-content: space-between;
        }

        .reply_wrap {
            display: flex;
            flex-direction: column;
            align-items: flex-end;
            margin-top: 5rem;
        }

        .textarea {
            width: 100%;
            height: 6rem;
            border: 1px solid #E1E1E1;
            padding: 0.2rem;
        }

        .btn {
            background: #0689FB;
            width: 4rem;
            height: 1.5rem;
            text-align: center;
            line-height: 1.5rem;
            color: #fff;
            margin: 0.5rem 0;
            border-radius: 0.2rem;
        }

        .headimgurl {
            width: 2.2rem;
            height: 2.2rem;
            border-radius: 50%;
            overflow: hidden;
        }

        .swiper-slide {
            height: 5rem;
        }
    </style>
</head>

<body>
    <div id="app">
        <div class="aui-content-padded" style="font-size:0.6rem;">
            <div class="user_head_info">
                <div class="headimgurl"><img :src="info.headimgurl" alt=""></div>
                <div style="width:calc(100% - 2.5rem);">
                    <div class="list-item-inner" style="margin-bottom:0.3rem;">
                        <div class="list-item-title">{{info.user_name}}</div>
                        <div class="list-item-right" style="color:#C2C2C2;"><small>{{info.create_time}}</small></div>
                    </div>
                    <div class="list-item-inner">
                        <div class="list-item-title" style="color:#C2C2C2;"></div>
                        <div class="list-item-right" style="color:#C2C2C2;"><small>星级评分：{{info.score}}</small></div>
                    </div>
                </div>
            </div>
            <div>{{info.comment}}</div>
            <div class="swiper-container" style="margin:0.5rem 0;">
                <div class="swiper-wrapper">
                    <div class="swiper-slide" v-for="o in info.comment_image_array"><img :src="o" alt=""></div>
                </div>
            </div>
            <div style="background:#F3F3F3;padding:0.5rem;" v-if="info.comment_status == 2">
                <div>工人回复：</div>
                <div>{{info.reply_comment}}</div>
            </div>

            <!-- 发表回复 -->
            <div class="reply_wrap" v-if="info.comment_status == 1">
                <div style="font-size:0.8rem;">发表回复</div>
                <textarea class="textarea" v-model="reply_comment" placeholder="请输入回复内容"></textarea>
                <div class="btn" @click="submit()">提交</div>
            </div>

        </div>
    </div>
</body>
<script src="../../../script/api.js" charset="utf-8"></script>
<script src="../../../script/aui/aui-tab.js" charset="utf-8"></script>
<script src="../../../script/common/jquery-3.3.1.min.js" charset="utf-8"></script>
<script src="../../../script/common/swiper.min.js" charset="utf-8"></script>
<script src="../../../script/common/common.js" charset="utf-8"></script>
<script src="../../../script/common/config.js" charset="utf-8"></script>
<script src="../../../script/common/vue.min.js" charset="utf-8"></script>
<script>
    apiready = function() {
        api.parseTapmode();
        vm.init();


    }

    var vm = new Vue({
        el: "#app",
        data: {
            userInfo: {},
            orderInfo: {},
            info: {},
            reply_comment: ''
        },
        methods: {
            init() {
                this.userInfo = get_local("userInfo");
                this.orderInfo = api.pageParam;
                this.getComment();
            },
            getComment() {
                var that = this;
                var data = {
                    order_id: this.orderInfo.order_id,
                    work_id: this.orderInfo.work_id,
                    work_user_id: this.orderInfo.work_user_id,
                    accept_user_id: this.orderInfo.accept_user_id,
                };
                _ajax(Config.api.AcceptUserGetComment, data, function(ret) {
                    if (ret.code === 200) {
                        that.info = ret.data;
                        setTimeout(function() {
                            var swiper = new Swiper('.swiper-container', {
                                slidesPerView: 3,
                                spaceBetween: 10,
                            });
                        }, 200);
                    }
                });
            },
            submit() {
                var that = this;
                var data = {
                    order_id: this.orderInfo.order_id,
                    work_id: this.orderInfo.work_id,
                    work_user_id: this.orderInfo.work_user_id,
                    accept_user_id: this.orderInfo.accept_user_id,
                    comment_id: this.info.comment_id,
                    reply_comment: this.reply_comment
                };
                _ajax(Config.api.AcceptUserReplyComment, data, function(ret) {
                    if (ret.code === 200) {
                        that.getComment();
                        $toast("回复评论成功");
                    } else {
                        $toast("回复评论失败");
                    }
                });
            }
        }
    });
</script>

</html>
